// pages/userInfoCenter/index.js
const App = getApp();
const {Dialog} = require("../../../../../config/modal")
const utils = require("../../../../../utils/util")
Page({
    /**
     * 页面的初始数据
     */
    data: {
        theamTextColor: App.globalData.theamTextColor,
        integral: {
            orderNo: '',
            progress: {},
            progressActive: 1,
        },
    },
    URL: {
        getList: "/integral/goods/getList",
        progress:"/integral/progress/?"
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        wx.hideShareMenu();
        this.setData({
            'integral.orderNo': options.orderNo
        })
    },
    onShow() {
        this.initProgress();
    },
    copyOrder(e){
        let order = e.currentTarget.dataset.order;
        wx.setClipboardData({
            data: order,
            success: function (res) {
                wx.getClipboardData({
                    success: function () {
                        wx.showToast({
                            title: '已复制',
                            icon:'none'
                        })
                    }
                })
            }
        })
    },


    // 获取积分
    initProgress() {
        App.$get(true, this.URL.progress.replace('?', this.data.integral.orderNo), {}, res => {
            if (res.R) {
                wx.stopPullDownRefresh();
                this.setData({
                    'integral.progress': res.data
                })
                for (const item in res.data.progress) {
                    if(res.data.progress[item].isCurrentStatus){
                        this.setData({
                           'integral.progressActive':item
                        })
                        break;
                    }
                }
            }
        })
    },

    goBack() {
        wx.navigateBack();
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {
        this.initProgress();
    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },
    setLoadingMore(show, type, text) {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})
